<template>
	<view class="mainpadding">
		<view class="xiahuaxian flexbetween shangbj" v-for="item in list.data" :key="item.id" @click="jumper('/pages_homepage/gerenzhuye?id=',item.user1.id)">
			<view class="flexleft">
				<image class="touxiang margin_right3" :src="item.user1.avatar_text" mode=""></image>
				<view class="">
					<view class="titletext" style="color: #FAFCFF;">{{item.user1.nickname}}</view>
					<view class="margin_top2 ershil" style="color: #969293;">关注了他{{item.createtime_text}}</view>
				</view>
			</view>
			<view class="weigbtn flexcenter" @click="gz_fn(item,item.user1.id)">已关注</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			jumper(url, val) {
				uni.navigateTo({
					url: url + val
				})
			},
			gz_fn(item,id) {
				httpRequest.request('/api/user/clUserGz', 'GET', {
					b_user_id: id
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.init()
						uni.$emit("guanzhuemitfn", {is_gz:item.is_gz==0?1:0,frienduser_id:id})
					}
				})
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/user/getMyGzIndex', 'GET', {
					page: page || 1,
					limit: 12,
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.shangbj {
		margin-top: 30rpx;
	}

	.shangbj:first-child {
		margin-top: 0rpx;
	}

	.ygbtn {
		width: 106rpx;
		height: 55rpx;
		background: rgba(221, 80, 86, .2);
		border-radius: 39rpx 39rpx 39rpx 39rpx;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #DD5056;
	}

	.weigbtn {
		width: 106rpx;
		height: 55rpx;
		background: #DD5056;
		border-radius: 39rpx 39rpx 39rpx 39rpx;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.touxiang {
		width: 118rpx;
		height: 118rpx;
		border-radius: 50%;
	}
</style>